﻿using EasyToHelp.DBFactory;
using EasyToHelp.Entity;
using System;
using System.Collections.Generic;
using System.Text;

namespace EasyToHelp.Service
{
    /// <summary>
    /// 身份证信息
    /// </summary>
    public class CardInfoService: ICardInfoService
    {
        #region 新增
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int Add(CardInfo model)
        {
            return DBHelper.InsertExecute<CardInfo>(model).Id;
        }
        #endregion

        #region 更新
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int Update(CardInfo model)
        {
            return DBHelper.UpdateExecute<CardInfo>(model);
        }
        #endregion

        #region 删除
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int Delete(CardInfo model)
        {
            return DBHelper.DeleteExecute<CardInfo>(model);
        }
        #endregion

        #region 获取所有
        /// <summary>
        /// 获取所有
        /// </summary>
        /// <returns></returns>
        public List<CardInfo> GetList()
        {
            using (var db = ContextHelper.Context(ContextHelper._connString))
            {
                return db.Query<CardInfo>().ToList();
            }
        }
        #endregion
    }
}
